import { Router } from '@angular/router';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class UserService {
  private state: object = {
    userInfo: {},
    token: ''
  }
  constructor(private router: Router) { }
  get(item: string): any {
    return this.state[item]
  }
  set(item: any, value: any): void {
    if (this.state.hasOwnProperty(item)) {
      this.state[item] = value
    }
  }
  logOut() {
    localStorage.removeItem('USER_TOKEN')
    this.router.navigateByUrl('/login')
  }
}
